/*
	Copyright 2006, 2007, 2008, 2009, 2010 Bastiaan Grutters
    
    This file is part of Ages of Strife website.

    Ages of Strife website is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Ages of Strife website is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Ages of Strife website.  If not, see <http://www.gnu.org/licenses/>.
 */
YAHOO.util.Event.addListener( window, 'load', tabsInit );

var countTabAnimation = Array();

function tabsInit() {
    /*var oMenuBar = new YAHOO.widget.MenuBar( "header", { autosubmenudisplay: true, hidedelay: 750, lazyload: true } );
    oMenuBar.render();*/
	
	var highlighted = YAHOO.util.Dom.getElementsByClassName( 'highlight', 'a', document.getElementById( 'header' ) );
	for( var i in highlighted ) {
		if( !YAHOO.util.Dom.hasClass( highlighted[i], 'selected' ) ) {
			countTabAnimation[highlighted[i].innerHTML] = 0;
			var attributes = {
				backgroundColor: { to: '#DCBC6E', from: '#AC8C3E' }
			}
			var tabAnim = new YAHOO.util.ColorAnim( highlighted[i], attributes, 1, YAHOO.util.Easing.easeBoth );
			tabAnim.onComplete.subscribe( continueTabAnimation );
			tabAnim.animate();
		}
	}
}

function continueTabAnimation( event, info ) {
	var el = this.getEl();
	var attributes;
	countTabAnimation[el.innerHTML] ++;
	
	if( countTabAnimation[el.innerHTML] < 7 ) {
		if( YAHOO.util.Dom.hasClass( el, 'fade-in' ) ) {
			YAHOO.util.Dom.removeClass( el, 'fade-in' );
			attributes = {
				backgroundColor: { to: '#DCBC6E', from: '#AC8C3E' }
			}
		}
		else {
			YAHOO.util.Dom.addClass( el, 'fade-in' );
			attributes = {
				backgroundColor: { from: '#DCBC6E', to: '#AC8C3E' }
			}
		}
		var tabAnim = new YAHOO.util.ColorAnim( el, attributes, 1, YAHOO.util.Easing.easeBoth );
		tabAnim.onComplete.subscribe( continueTabAnimation );
		tabAnim.animate();
	}
}